package com.wanbangee.marksystem.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.wanbangee.marksystem.entities.MExamMarker;
import com.wanbangee.marksystem.entities.SScore;
import com.wanbangee.marksystem.service.RepeatService;
import com.wanbangee.marksystem.service.score.SettingScoreService;

@RestController
@RequestMapping("repeat")
public class RepeatController {
	
	@Autowired
	private SettingScoreService settingScoreService;
	
	@Autowired
	private RepeatService repeatService;

	/**
	 * 获取重评列表
	 */
	@GetMapping("selectRepeatList/{teaId}/{schId}")
	public Map selectRepeatList(@PathVariable("teaId")Integer teaId,@PathVariable("schId")Integer schId) {
		List<MExamMarker> mExamMarkers = settingScoreService.selectMExamMarkersRepeatList(teaId, schId);
		HashMap<String,Object> map = new HashMap<>();
		if(mExamMarkers.size()==0) {
			map.put("code", 10013);
			map.put("result", null);
		}else {
			mExamMarkers = repeatService.selectRepeatList(mExamMarkers);
			map.put("code", 1001);
			map.put("result", mExamMarkers);
		}
		
		return map;
		
	}
	/**
	 * 获取重评问题信息
	 * @param examId
	 * @param examSubId
	 * @param markerId
	 * @param teaId
	 * @param topicNo
	 * @return
	 */
	@GetMapping("selectRepeatInfo/{examId}/{examSubId}/{markerId}/{topicNo}/{teaId}")
	public Map selectRepeatInfo(@PathVariable("examId")Integer examId,@PathVariable("examSubId")Integer examSubId,@PathVariable("markerId")Integer markerId,@PathVariable("teaId")Integer teaId,@PathVariable("topicNo")Integer topicNo) {
		
		List<SScore> sScores = repeatService.selectRepeatInfo(examId, examSubId, markerId, topicNo, teaId);
		HashMap<String,Object> map = new HashMap<>();
		if(sScores.size()==0) {
			map.put("code", 10013);
			map.put("result", null);
		}else {
		
			map.put("code", 1001);
			map.put("result", sScores);
		}
		
		return map;
	}
	
	
}
